<template>
	<view class="u-page">
		<card title="基础功能">
			<u-swiper
				:list="list1"
				@change="change"
				@click="click"
			></u-swiper>
		</card>
		<card title="带标题">
			<u-swiper
				:list="list2"
				keyName="image"
				showTitle
				:autoplay="false"
				circular
			></u-swiper>
		</card>
		<card title="带指示器">
			<u-swiper
				:list="list3"
				indicator
				indicatorMode="line"
				circular
			></u-swiper>
		</card>
		<card title="加载中">
			<u-swiper
				:list="list3"
				loading
			></u-swiper>
		</card>
		<card title="嵌入视频">
			<u-swiper
				:list="list4"
				keyName="url"
				:autoplay="false"
			></u-swiper>
		</card>
		<card title="自定义指示器">
			<u-swiper
				:list="list5"
				@change="e => current = e.current"
				:autoplay="false"
			>
				<view
					slot="indicator"
					class="indicator"
				>
					<view
						class="indicator__dot"
						v-for="(item, index) in list5"
						:key="index"
						:class="[index === current && 'indicator__dot--active']"
					>
					</view>
				</view>
			</u-swiper>
			<u-gap
				bgColor="transparent"
				height="15"
			></u-gap>
			<u-swiper
				:list="list6"
				@change="e => currentNum = e.current"
				:autoplay="false"
				indicatorStyle="right: 20px"
			>
				<view
					slot="indicator"
					class="indicator-num"
				>
					<text class="indicator-num__text">{{ currentNum + 1 }}/{{ list6.length }}</text>
				</view>
			</u-swiper>
		</card>
		<!-- #ifndef MP-TOUTIAO -->
		<card title="卡片式">
			<u-swiper
				:list="list3"
				previousMargin="30"
				nextMargin="30"
				circular
				:autoplay="false"
				radius="5"
				bgColor="#ffffff"
			></u-swiper>
		</card>
		<!-- #endif -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				current: 0,
				currentNum: 0,
				list: [{
						// image: 'http://uview.d3u.cn/web/static/uview/resources/video.mp4',
						image: 'http://uview.d3u.cn/web/static/uview/album/1.jpg',
						title: '昨夜星辰昨夜风，画楼西畔桂堂东',
						poster: 'http://uview.d3u.cn/web/static/uview/album/1.jpg'
					},
					{
						image: 'http://uview.d3u.cn/web/static/uview/album/2.jpg',
						title: '身无彩凤双飞翼，心有灵犀一点通'
					},
					{
						image: 'http://uview.d3u.cn/web/static/uview/album/3.jpg',
						title: '谁念西风独自凉，萧萧黄叶闭疏窗，沉思往事立残阳'
					}
				],
				list1: [
					'http://uview.d3u.cn/web/static/uview/album/1.jpg',
					'http://uview.d3u.cn/web/static/uview/album/2.jpg',
					'http://uview.d3u.cn/web/static/uview/album/3.jpg',
				],
				list2: [{
						image: 'http://uview.d3u.cn/web/static/uview/album/2.jpg',
						title: '昨夜星辰昨夜风，画楼西畔桂堂东',
						type: 'image',
					},
					{
						image: 'http://uview.d3u.cn/web/static/uview/album/1.jpg',
						title: '身无彩凤双飞翼，心有灵犀一点通'
					},
					{
						image: 'http://uview.d3u.cn/web/static/uview/album/3.jpg',
						title: '谁念西风独自凉，萧萧黄叶闭疏窗，沉思往事立残阳'
					}
				],
				list3: [
					'http://uview.d3u.cn/web/static/uview/album/3.jpg',
					'http://uview.d3u.cn/web/static/uview/album/2.jpg',
					'http://uview.d3u.cn/web/static/uview/album/1.jpg',
				],
				list4: [{
						url: 'http://uview.d3u.cn/web/static/uview/resources/video.mp4',
						title: '昨夜星辰昨夜风，画楼西畔桂堂东',
						poster: 'http://uview.d3u.cn/web/static/uview/album/1.jpg',
					},
					{
						url: 'http://uview.d3u.cn/web/static/uview/album/2.jpg',
						title: '身无彩凤双飞翼，心有灵犀一点通'
					},
					{
						url: 'http://uview.d3u.cn/web/static/uview/album/3.jpg',
						title: '谁念西风独自凉，萧萧黄叶闭疏窗，沉思往事立残阳'
					}
				],
				list5: [
					'http://uview.d3u.cn/web/static/uview/album/3.jpg',
					'http://uview.d3u.cn/web/static/uview/album/2.jpg',
					'http://uview.d3u.cn/web/static/uview/album/1.jpg',
				],
				list6: [
					'http://uview.d3u.cn/web/static/uview/album/2.jpg',
					'http://uview.d3u.cn/web/static/uview/album/3.jpg',
					'http://uview.d3u.cn/web/static/uview/album/1.jpg',
				]
			}
		},
		methods: {
			change(e) {
				// console.log('change', e);
			},
			click(e) {
				console.log('click', e);
			}
		},
	}
</script>

<style lang="scss">
	.indicator {
		display: flex;
		flex-direction: row;
		justify-content: center;

		&__dot {
			height: 6px;
			width: 6px;
			border-radius: 100px;
			background-color: rgba(255, 255, 255, 0.35);
			margin: 0 5px;
			transition: background-color 0.3s;

			&--active {
				background-color: #ffffff;
			}
		}
	}

	.indicator-num {
		padding: 2px 0;
		background-color: rgba(0, 0, 0, 0.35);
		border-radius: 100px;
		width: 35px;
		display: flex;
		flex-direction: row;
		justify-content: center;

		&__text {
			color: #FFFFFF;
			font-size: 12px;
		}
	}
</style>
